package Game.Spawners;

import java.util.ArrayList;
import java.util.List;

import org.newdawn.slick.SlickException;

import Game.GameHelper;
import Game.Level;
import Game.Objects.GOTorch;
import GameMath.GPoint;

/** Spawn Torches class
 * @author Aikidos
 */
public class SpawnTorches extends SpawnerBase {

	@Override
	public void spawn(Level level) throws SlickException {
		int numOfTorches = GameHelper.getRandom().nextInt(3);
		for (int i = 0; i < numOfTorches; i++) {
			List<GPoint> banCoords = new ArrayList<GPoint>();
			banCoords.add(level.getObjectManager().getPlayer().getCoord());
			
			if (!level.isUndergroundTown()) {
				banCoords.add(level.getObjectManager().getObjectsByClass("Game.Objects.GOLever")[0].getCoord());
				banCoords.add(level.getObjectManager().getObjectsByClass("Game.Objects.GOAltar")[0].getCoord());
			}
				
			banCoords.add(level.getObjectManager().getObjectsByClass("Game.Objects.GOTrapdoor")[0].getCoord());
			
			GOTorch newTorch = new GOTorch(level.getObjectManager());
			
			level.getObjectManager().spawnObject(newTorch, banCoords);
			newTorch.initLight();
		}
	}

}
